package com.colin.videoservice;

import com.colin.core.PathCollect;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;

import java.util.List;

@SpringBootApplication
@EnableEurekaClient
//@MapperScan("com.colin.videoservice.mapper")
public class VideoServiceApplication implements InitializingBean {

    @Autowired
    private PathCollect pathCollect;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public static void main(String[] args) {
        SpringApplication.run(VideoServiceApplication.class, args);
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        List<String> loginCheckPathList = pathCollect.getLoginCheckPath();
        for (String loginCheckPath : loginCheckPathList) {
            rabbitTemplate.convertAndSend("path.collect", loginCheckPath);
        }
    }
}
